<?php

declare(strict_types=1);

namespace App\CustHub\Constants;

use App\Common\Constants\AbstractBaseConstants;
use Hyperf\Constants\Annotation\Constants;

#[Constants]
class MsgTypeConstants extends AbstractBaseConstants
{
    /**
     * @Message("文本消息")
     */
    const TEXT = 'text';

    /**
     * @Message("混合文本消息")
     */
    const MIXED_TEXT = 'mixed_text';

    /**
     * @Message("图片消息")
     */
    const IMAGE = 'image';

    /**
     * @Message("视频消息")
     */
    const VIDEO = 'video';

    /**
     * @Message("文件消息")
     */
    const FILE = 'file';

    /**
     * @Message("链接消息")
     */
    const URL = 'url';

    /**
     * @Message("小程序消息")
     */
    const MINI_PROGRAM = 'mini_program';

    /**
     * 自定义
     * @Message("小程序消息")
     */
    const CUSTOM_MINI_PROGRAM = 'custom_mini_program';

    /**
     * @Message("表情消息")
     */
    const EMOJI = 'emoji';

    /**
     * @Message("表情消息")
     */
    const GIF = 'gif';

    /**
     * @Message("群邀请消息")
     */
    const CROWD = 'crowd';

    /**
     * @Message("退订消息")
     */
    const UNSUBSCRIBE = 'return';

    /**
     * @Message("视频号")
     */
    const VIDEO_CHANNEL = 'video_channel';

    /**
     * @Message("名片")
     */
    const BUSINESS_CARD = 'business_card';

    /**
     * @Message("红包")
     */
    const RED_PACKET = 'red_packet';

    /**
     * @Message("问卷调查")
     */
    const QUESTIONNAIRE = 'questionnaire';

    /**
     * @Message("群通知")
     */
    const CROWD_NOTICE = 'notice';

    /**
     * @Message("名片消息")
     */
    const PERSONAL_CARD = 'personal_card';

    /**
     * @Message("定位消息")
     */
    const LOCATION = 'location';

    /**
     * @Message("极速群发")
     */
    const SPEED = 'speed';

    public static function getMsgType(int $type): string
    {
        return match ($type) {
            0,2 => self::TEXT,
            14,101 => self::IMAGE,
            29,104 => self::EMOJI,
            15,20,102 => self::FILE,
            23,22,103 => self::VIDEO,
            78 => self::MINI_PROGRAM,
            13 => self::URL,
            141 => self::VIDEO_CHANNEL,
            4 => self::MIXED_TEXT,
            26 => self::RED_PACKET,
            default => -1,
        };
    }


    public static function collectMsgTypes(): array
    {
        return [
            self::TEXT,
            self::IMAGE,
            self::EMOJI,
            self::FILE,
            self::VIDEO,
            self::MINI_PROGRAM,
            self::URL,
            self::VIDEO_CHANNEL
        ];
    }
}